fbee6fdd1daf65191712e0f8ac8774575cf7d1e3,drools-core/src/main/java/org/drools/common/AbstractRuleBase.java,AbstractRuleBase,removeRule,#String#String#,397
Before Change
final Rule rule = pkg.getRule( ruleName );
// Iterate each workingMemory and lock it
// This is so we don't update the Rete network during propagation
for ( final Iterator it = this.workingMemories.keySet().iterator(); it.hasNext(); ) {
final AbstractWorkingMemory workingMemory = (AbstractWorkingMemory) it.next();
workingMemory.getLock().lock();
}
removeRule( rule );
pkg.removeRule( rule );
// Iterate and unlock
for ( final Iterator it = this.workingMemories.keySet().iterator(); it.hasNext(); ) {
final AbstractWorkingMemory workingMemory = (AbstractWorkingMemory) it.next();
workingMemory.getLock().unlock();
}
}
After Change
int lastAquiredLock = 0;
// get a snapshot of current working memories for locking
AbstractWorkingMemory[] wms = (AbstractWorkingMemory[]) this.workingMemories.keySet().toArray( new AbstractWorkingMemory[this.workingMemories.size()] );
try {
// Iterate each workingMemory and lock it
// This is so we don't update the Rete network during propagation
for ( lastAquiredLock = 0; lastAquiredLock < wms.length; lastAquiredLock++ ) {
wms[lastAquiredLock].getLock().lock();
}
removeRule( rule );